# Save project before running this
aprx = arcpy.mp.ArcGISProject("CURRENT")

# Show list of maps
aprx.listMaps()
i=0
for mp in aprx.listMaps():
    print( str(i)+": "+mp.name)
    i=i+1


# Select the Map you want to work with 
Select = 0
mpr = aprx.listMaps()[Select]

# Show list of Layers
i=0
for m in mpr.listLayers():
    print( str(i) + ": "+ m.name )
    i=i+1

# Select the boundaries of the layers to be changed
unvis0 = 0
unvis1 = 8

# Show list of layouts
aprx.listLayouts()
i=0
for ly in aprx.listLayouts():
    print(str(i)+": "+ly.name)
    i=i+1

# Don't change anything in this function unless you know what are you doing
# But run the cell to define the function
def onlyvis(mpr,novis0,novis1,vis):
    # Makes everything invisible from novis0 to novis1 then makes vis visible in the mpr map
    i=novis0
    for m in mpr.listLayers()[novis0:novis1]:
        m.visible = False
        if (novis0==vis):
            print( str(i)+": "+m.name)
        i=i+1

    mpr.listLayers()[vis].visible = True


# Fill the list with the saving path, must be a raw string define as r"STRING"
# Remember it must match the position shown on cell 6.
pathto = [
    r"C:\temp\DPT_High.png",
    r"C:\temp\DPT_Low-.png",
    r"C:\temp\DPT_Medi.png",
    r"C:\temp\VEL_High.png",
    r"C:\temp\VEL_Low-.png",
    r"C:\temp\VEL_Medi.png",
    r"C:\temp\WSE_High.png",
    r"C:\temp\WSE_Low-.png",
    r"C:\temp\WSE_Medi.png"
]

# Create a vector with what layout each variable will be using
# In this example 0 is Velocity, 1 is WSE and 2 is Depth as per cell 8.
# It must match the position of the cell 6

layoutsel = [0,0,0,2,2,2,1,1,1]

for j in range(len(layoutsel)):
    # Select layout from layoutsel
    lyd = aprx.listLayouts()[layoutsel[j]]
    exppath = pathto[j]
    # Change map to only visible
    onlyvis(mpr,unvis0,unvis1+1,j+unvis0)
    # Export
    print("Exporting : "+str(j)+" : "+exppath)
    lyd.exportToPNG(exppath,resolution = 300)
print("FINISHED")
